package com.qysoft.dtkj.dtkj_gl.actions.xtwh;


import java.util.List;

import com.jfinal.aop.Before;
import com.jfinal.aop.Clear;
import com.jfinal.plugin.ehcache.CacheKit;
import com.qysoft.dtkj.dtkj_gl.services.xtwh.ZYGLService;
import com.qysoft.rapid.actions.JsonResultInterceptor;
import com.qysoft.rapid.actions.RapidAction;
import com.qysoft.rapid.core.RapidDbConn;
import com.qysoft.rapid.core.RapidDbConnTx;
import com.qysoft.rapid.domain.Bean;
import com.qysoft.rapid.shiro.RapidShiroInterceptor;

@Before(JsonResultInterceptor.class)
public class ZYGLAction extends RapidAction{

	@Clear(JsonResultInterceptor.class)
	public void index(){
		renderJsp("/WEB-INF/pages/xtwh/zygl.jsp");
	}
	
	@Before(RapidDbConnTx.class)
	public void saveZYXX() throws Exception{
		Bean zyxx = getBean();
		ZYGLService.saveZYXX(zyxx);
		//重置shiro拦截器
		RapidShiroInterceptor.resetUrl();
	}

	@Before(RapidDbConnTx.class)
	public void delete() throws Exception{
		String zyid = getPara("zyid");
		ZYGLService.delete(zyid);
		//重置shiro拦截器
		RapidShiroInterceptor.resetUrl();
	}
	
	@Before(RapidDbConn.class)
	public void queryZYXX() throws Exception{
		String zyid = getPara("zyid");
		Bean zyxx = ZYGLService.queryZYXX(zyid);
		setJson(zyxx);
	}
	
	@Before(RapidDbConnTx.class)
	public void updateZYXX() throws Exception{
		Bean zyxx = getBean();
		ZYGLService.updateZYXX(zyxx);
		//重置shiro拦截器
		RapidShiroInterceptor.resetUrl();
		//重置所有人授权的资源缓存
		CacheKit.removeAll("permissions");
	}
	
	@Before(RapidDbConn.class)
	public void queryZyxxForTree() throws Exception{
		List<Bean> zyxxList = ZYGLService.queryZyxxForTree();
		setJson(zyxxList);
	}
	
	@Before(RapidDbConn.class)
	public void queryJsZy() throws Exception{
		String jsid = getPara("id");
		String zyids = ZYGLService.queryJsZy(jsid);
		setJson(zyids);
	}
}
